/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author sultan
 */

import java.awt.event.KeyEvent;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.*;
import net.proteanit.sql.DbUtils;

public class UserUpdate extends javax.swing.JFrame {
    String UserName;
    String FarmName;
    Connection conn=null;
    ResultSet rs =null;
    PreparedStatement pst=null;
    
   
    /**
     * Creates new form UserUpdate
     */
    public UserUpdate() {
       initComponents();
       conn=DataBaseConect.ConnectDb();
       UpdateTable();
       CurrentDate();
       UpdateStock();
    }
    //our constructor
    public UserUpdate(String LogedUser,String GetFormName){
        UserName=LogedUser;
        FarmName = GetFormName;
        initComponents();
        conn=DataBaseConect.ConnectDb();
        CurrentDate();
        UpdateTable();
        UpdateStock();
    }
    public void JournalSaved (){
    if(JournalName.getText().isEmpty()){
            JOptionPane.showMessageDialog(null, "Pleas Write the Name");
        }
        else if(JournalDetail.getSelectedItem().equals("Non")){
            JOptionPane.showMessageDialog(null, "Pleas Choose Correct Detail");
        }
        else if(JournalDetail.getSelectedItem().equals("Others")&&OtherExpenseDetail.getText().isEmpty()){
            JOptionPane.showMessageDialog(null, "Please Write the Expense Type");
        }
        else if(JournalQty.getText().isEmpty()){
            JOptionPane.showMessageDialog(null, "Pleas Type Quantity");
        }
        else if(JournalRate.getText().isEmpty()){
            JOptionPane.showMessageDialog(null, "Pleas Type Rate");
        }
        else if(JournalMethod.getSelectedItem().equals("Non")){
            JOptionPane.showMessageDialog(null, "Pleas Choose Correct Paying Mathod");
        }
        else if (JournalDetail.getSelectedItem().equals("Layer")||JournalDetail.getSelectedItem().equals("Boiler")){
        try{  
        String sql = "insert into lifeSpane (Date,Name,user,Detail,Type,Quantity,Rate,Cost,"
                + "Method,LifeSpane,DateOfMiturity,FarmName) values (?,?,?,?,?,?,?,?,?,?,?,?)";
                pst=conn.prepareStatement(sql);
                pst.setString(1, PurchasedDate.getText());
                pst.setString(2, JournalName.getText());
                pst.setString(3, UserDisply.getText());
                //String value1=PurchasedDetail.getSelectedItem().toString();
                pst.setString(4, JournalDetail.getSelectedItem().toString());
                pst.setString(5, JournalType.getText());
                pst.setString(6, JournalQty.getText());
                pst.setString(7, JournalRate.getText());
                pst.setString(8, JournalCost.getText());
                pst.setString(9, JournalMethod.getSelectedItem().toString());
                if(JournalDetail.getSelectedItem().equals("Layer")){
                pst.setString(10, "2");
                pst.setString(11, FarmDisply.getText());
                }
                else{
                pst.setString(10, "40");
                }
                if(JournalDetail.getSelectedItem().equals("Layer")){
                Calendar cal = Calendar.getInstance();
                cal.add(Calendar.YEAR, 2);
                SimpleDateFormat DateFormat= new SimpleDateFormat("yyyy-MM-dd");
                String dt = DateFormat.format(cal.getTime());
                pst.setString(11, dt);
                }
                else{
                Calendar cal = Calendar.getInstance();
                cal.add(Calendar.DATE, 40);
                SimpleDateFormat DateFormat= new SimpleDateFormat("yyyy-MM-dd");
                String dt = DateFormat.format(cal.getTime());
                pst.setString(11, dt);
                }
                pst.execute();
                JOptionPane.showMessageDialog(null, "Sved to Life Span Table");
                JournalType.setText("Type");
                JournalName.setText("");
                OtherExpenseDetail.setText("");
                JournalDetail.setSelectedIndex(0);    
                JournalQty.setText("");
                JournalRate.setText("");
                JournalCost.setText("Cost");
                ShowJournalId.setText("");
                JournalMethod.setSelectedIndex(0);
                }
                catch(Exception e){
                e.printStackTrace();
                JOptionPane.showMessageDialog(null, e);
                }finally{
                try{
                rs.close();
                pst.close();
                }
                catch(Exception e){}
                }
                }
        else {
            try{
                String sql = "insert into journal (Date,user,detail,type,quantity,rate,cost,method,Name,FarmName)"
                        + " values (?,?,?,?,?,?,?,?,?,?)";
                pst=conn.prepareStatement(sql);
                pst.setString(1, PurchasedDate.getText());
                pst.setString(2, UserDisply.getText());
                if(JournalDetail.getSelectedItem().equals("Others")){
                pst.setString(3, OtherExpenseDetail.getText());
                }
                else{
                pst.setString(3, JournalDetail.getSelectedItem().toString());}
                pst.setString(4, JournalType.getText());
                pst.setString(5, JournalQty.getText());
                pst.setString(6, JournalRate.getText());
                pst.setString(7, JournalCost.getText());
                String value2=JournalMethod.getSelectedItem().toString();
                pst.setString(8, value2);
                pst.setString(9, JournalName.getText());
                pst.setString(10, FarmDisply.getText());
                pst.execute();
                JOptionPane.showMessageDialog(null, "Sved to Journal Table");
                JournalType.setText("Type");
                JournalName.setText("");
                JournalDetail.setSelectedIndex(0);
                JournalQty.setText("");
                OtherExpenseDetail.setText("");
                JournalRate.setText("");
                JournalCost.setText("Cost");
                ShowJournalId.setText("");
                JournalMethod.setSelectedIndex(0);
            }
            catch(Exception e){
                e.printStackTrace();
                JOptionPane.showMessageDialog(null, e);
            }finally{
                try{
                    rs.close();
                    pst.close();
                }
                catch(Exception e){}
            }
        }
        UpdateTable();
        UpdateStock();
    
    
    }
    
    public void UpdateStock(){
    try{  
        String sql="select *,sum(quantity) from journal where detail = 'Hen'or detail='Layer'or detail='Boiler'";
        pst=conn.prepareStatement(sql);
        rs=pst.executeQuery();
        int GetSumHenjournal=Integer.parseInt(rs.getString("sum(quantity)"));
        String sqla0="select *,sum(quantity) from sales where detail = 'Hen'";
        pst=conn.prepareStatement(sqla0);
        rs=pst.executeQuery();
        int GetSumHenSale=Integer.parseInt(rs.getString("sum(quantity)"));
        int RemnaingHen=GetSumHenjournal-GetSumHenSale;
        //String ConvetToString=String.valueOf(RemnaingHen);
        StockHen.setText(String.valueOf(RemnaingHen));
        
        String sql1="select *,sum(quantity) from journal where detail = 'Cock'";
        pst=conn.prepareStatement(sql1);
        rs=pst.executeQuery();
        int GetSumCockpurchase=Integer.parseInt(rs.getString("sum(quantity)"));
        String sqla1="select *,sum(quantity) from sales where detail = 'Cock'";
        pst=conn.prepareStatement(sqla1);
        rs=pst.executeQuery();
        int GetSumCockSale=Integer.parseInt(rs.getString("sum(quantity)"));
        int RemnaingCock=GetSumCockpurchase-GetSumCockSale;
        //String ConvToString=String.valueOf(RemnaingCock);
        StockCock.setText(String.valueOf(RemnaingCock));
        
        String sql2="select *,sum(quantity) from journal where detail = 'Feed' and type ='Purchase'";
        pst=conn.prepareStatement(sql2);
        rs=pst.executeQuery();
        int GetPurchFeed=Integer.parseInt(rs.getString("sum(quantity)"));
        String sqla2="select *,sum(quantity) from journal where detail = 'Feed' and type ='Consumption'";
        pst=conn.prepareStatement(sqla2);
        rs=pst.executeQuery();
        int GetConFeed=Integer.parseInt(rs.getString("sum(quantity)"));
        String sqlb2="select *,sum(quantity) from sales where detail = 'Feed'";
        pst=conn.prepareStatement(sqlb2);
        rs=pst.executeQuery();
        int GetSaleFeed=Integer.parseInt(rs.getString("sum(quantity)"));
        int RemnaingFeed=GetPurchFeed-(GetConFeed+GetSaleFeed);
        StockFeed.setText(String.valueOf(RemnaingFeed));
        
        String sql3="select *,sum(quantity) from journal where detail = 'Eggs'";
        pst=conn.prepareStatement(sql3);
        rs=pst.executeQuery();
        int GetPurchEggs=Integer.parseInt(rs.getString("sum(quantity)"));
        String sqla3="select *,sum(quantity) from sales where detail = 'Eggs'";
        pst=conn.prepareStatement(sqla3);
        rs=pst.executeQuery();
        int GetSaleEggs=Integer.parseInt(rs.getString("sum(quantity)"));
        int RemnaingEggs=GetPurchEggs-GetSaleEggs;
        StockEggs.setText(String.valueOf(RemnaingEggs));
    }
        catch(Exception e){
        e.printStackTrace();
	JOptionPane.showMessageDialog(null, e);
        }finally{
        try{
        rs.close();
        pst.close();
           }
        catch(Exception e){}
            }
    } 
    
    
    private void UpdateTable(){
    try{
        String sql="select sr,Date,detail,type ,quantity from journal where type = 'Production'or type='Consumption'";
        pst=conn.prepareStatement(sql);
        rs=pst.executeQuery();
        StockTable.setModel(DbUtils.resultSetToTableModel(rs));
        String sql1="select ID,Date,Detail,Type,Quantity from lifeSpane";
        pst=conn.prepareStatement(sql1);
        rs=pst.executeQuery();
        LifeSpaneTable.setModel(DbUtils.resultSetToTableModel(rs));
    }
    catch(Exception e){
    JOptionPane.showMessageDialog(null, e);
    }finally{
    try{
        rs.close();
        pst.close();
    }
    catch(Exception e){
    }
    }
    }
    
    public void CurrentDate(){
    SimpleDateFormat DateFormat= new SimpleDateFormat("yyyy-MM-dd");
    Calendar cal = Calendar.getInstance();
    String Date = DateFormat.format(cal.getTime());
    PurchasedDate.setText(Date);
    SaleDate.setText(Date);
    ProDate.setText(Date);
    LifeSpaneDate.setText(Date);
    }
     
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        JournalQty = new javax.swing.JTextField();
        JournalRate = new javax.swing.JTextField();
        JournalDetail = new javax.swing.JComboBox();
        JournalMethod = new javax.swing.JComboBox();
        SalesId1 = new javax.swing.JLabel();
        ShowJournalId = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        JournalName = new javax.swing.JTextField();
        PurchasedDate = new javax.swing.JLabel();
        OtherExpenseDetail = new javax.swing.JTextField();
        JournalType = new javax.swing.JLabel();
        JournalCost = new javax.swing.JLabel();
        jToolBar1 = new javax.swing.JToolBar();
        JournalSavetoolBar = new javax.swing.JButton();
        JournalClose = new javax.swing.JButton();
        JournalLogOut = new javax.swing.JButton();
        JournalSave = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        SaleQty = new javax.swing.JTextField();
        SaleRate = new javax.swing.JTextField();
        SaleDetail = new javax.swing.JComboBox();
        SaleMethod = new javax.swing.JComboBox();
        CustmerLable = new javax.swing.JLabel();
        SaleCustmer = new javax.swing.JTextField();
        SalesId = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        ShowSaleId = new javax.swing.JLabel();
        SaleDate = new javax.swing.JLabel();
        SaleType = new javax.swing.JLabel();
        SaleCost = new javax.swing.JLabel();
        SaleOtherDetail = new javax.swing.JTextField();
        jToolBar3 = new javax.swing.JToolBar();
        SaleSave1 = new javax.swing.JButton();
        SaleClose = new javax.swing.JButton();
        SaleLogOut = new javax.swing.JButton();
        SaleSave = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jPanel9 = new javax.swing.JPanel();
        jPanel10 = new javax.swing.JPanel();
        ProSave = new javax.swing.JButton();
        ProDetail = new javax.swing.JComboBox();
        ProQty = new javax.swing.JTextField();
        jLabel21 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        ProType = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        jLabel31 = new javax.swing.JLabel();
        ShowProId = new javax.swing.JLabel();
        ProDate = new javax.swing.JLabel();
        jPanel11 = new javax.swing.JPanel();
        StockFeed = new javax.swing.JLabel();
        StockHen = new javax.swing.JLabel();
        StockCock = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jLabel32 = new javax.swing.JLabel();
        StockEggs = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        StockTable = new javax.swing.JTable();
        jPanel12 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        LifeSpaneTable = new javax.swing.JTable();
        jPanel15 = new javax.swing.JPanel();
        jLabel28 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        jLabel30 = new javax.swing.JLabel();
        LifeSpaneId = new javax.swing.JLabel();
        jLabel34 = new javax.swing.JLabel();
        LifeSpaneDate = new javax.swing.JTextField();
        LifeSpaneDetail = new javax.swing.JComboBox();
        LifeSpaneType = new javax.swing.JLabel();
        LifeSpaneEdit = new javax.swing.JButton();
        jLabel33 = new javax.swing.JLabel();
        LifeSpaneQuantity = new javax.swing.JTextField();
        jPanel16 = new javax.swing.JPanel();
        LifeSpaneSearch = new javax.swing.JTextField();
        StockLable5 = new javax.swing.JLabel();
        StockLable6 = new javax.swing.JLabel();
        FarmDisply = new javax.swing.JLabel();
        SalesId2 = new javax.swing.JLabel();
        UserDisply = new javax.swing.JLabel();
        SalesId4 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        jMenuItem2 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Poultry Farmin System");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        jTabbedPane1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jPanel6.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel2.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel2.setText("Date:");

        jLabel3.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel3.setText("Detail:");

        jLabel4.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel4.setText("Type");

        jLabel5.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel5.setText("Quantity");

        jLabel6.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel6.setText("Rate");

        jLabel7.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel7.setText("Cost");

        jLabel8.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel8.setText("Method");

        JournalQty.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                JournalQtyKeyReleased(evt);
            }
        });

        JournalRate.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                JournalRateKeyReleased(evt);
            }
        });

        JournalDetail.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Non", "Hen", "Cock", "Eggs", "Salary", "Layer", "Boiler", "Feed", "Others" }));
        JournalDetail.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                JournalDetailItemStateChanged(evt);
            }
        });

        JournalMethod.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Non", "Cash", "Payable" }));

        SalesId1.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        SalesId1.setText("Procuct ID");

        ShowJournalId.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        ShowJournalId.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jLabel9.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel9.setText("Name");

        PurchasedDate.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

        JournalType.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        JournalType.setText("Type");

        JournalCost.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        JournalCost.setText("Cost");

        jToolBar1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jToolBar1.setRollover(true);

        JournalSavetoolBar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Save-icon.png"))); // NOI18N
        JournalSavetoolBar.setToolTipText("Save");
        JournalSavetoolBar.setFocusable(false);
        JournalSavetoolBar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        JournalSavetoolBar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        JournalSavetoolBar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JournalSavetoolBarActionPerformed(evt);
            }
        });
        jToolBar1.add(JournalSavetoolBar);

        JournalClose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Button-Close-icon.png"))); // NOI18N
        JournalClose.setToolTipText("Close");
        JournalClose.setFocusable(false);
        JournalClose.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        JournalClose.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        JournalClose.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JournalCloseActionPerformed(evt);
            }
        });
        jToolBar1.add(JournalClose);

        JournalLogOut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gnome_logout.png"))); // NOI18N
        JournalLogOut.setToolTipText("LogOut");
        JournalLogOut.setFocusable(false);
        JournalLogOut.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        JournalLogOut.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        JournalLogOut.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JournalLogOutActionPerformed(evt);
            }
        });
        jToolBar1.add(JournalLogOut);

        JournalSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icons/SaveBird.png"))); // NOI18N
        JournalSave.setText("Save");
        JournalSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JournalSaveActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(39, 39, 39)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel6Layout.createSequentialGroup()
                                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(96, 96, 96)
                                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(JournalDetail, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(JournalName)
                                        .addComponent(PurchasedDate, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(JournalType, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                            .addGroup(jPanel6Layout.createSequentialGroup()
                                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(96, 96, 96)
                                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(JournalMethod, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(JournalRate)
                                    .addComponent(JournalQty, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(JournalCost, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel6Layout.createSequentialGroup()
                                .addComponent(SalesId1, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(ShowJournalId, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(OtherExpenseDetail, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(183, 183, 183)
                        .addComponent(JournalSave)))
                .addContainerGap(99, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(53, 53, 53)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(ShowJournalId, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(SalesId1))
                        .addGap(8, 8, 8))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 4, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(PurchasedDate, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9)
                            .addComponent(JournalName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(JournalDetail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(OtherExpenseDetail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(JournalType))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(JournalQty, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(JournalRate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(JournalCost))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(JournalMethod, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8))))
                .addGap(18, 18, 18)
                .addComponent(JournalSave, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(57, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("     Journal    ", jPanel2);

        jPanel7.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel10.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel10.setText("Detail:");

        jLabel11.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel11.setText("Type");

        jLabel12.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel12.setText("Quantity");

        jLabel13.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel13.setText("Rate");

        jLabel14.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel14.setText("Cost");

        jLabel15.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel15.setText("Method");

        SaleQty.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                SaleQtyKeyReleased(evt);
            }
        });

        SaleRate.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                SaleRateKeyReleased(evt);
            }
        });

        SaleDetail.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Non", "Hen", "Cock", "Eggs", "Feed", "Others" }));
        SaleDetail.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                SaleDetailItemStateChanged(evt);
            }
        });

        SaleMethod.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Non", "Cash", "Receiveable", " " }));

        CustmerLable.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        CustmerLable.setText("Custmer");

        SalesId.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        SalesId.setText("Procuct ID");

        jLabel16.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel16.setText("Date:");

        ShowSaleId.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        ShowSaleId.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        SaleDate.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        SaleDate.setText("Date:");

        SaleType.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        SaleType.setText("Type");

        SaleCost.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        SaleCost.setText("Cost");

        jToolBar3.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jToolBar3.setRollover(true);

        SaleSave1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Save-icon.png"))); // NOI18N
        SaleSave1.setToolTipText("Save");
        SaleSave1.setFocusable(false);
        SaleSave1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        SaleSave1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        SaleSave1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SaleSave1ActionPerformed(evt);
            }
        });
        jToolBar3.add(SaleSave1);

        SaleClose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Button-Close-icon.png"))); // NOI18N
        SaleClose.setToolTipText("Close");
        SaleClose.setFocusable(false);
        SaleClose.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        SaleClose.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        SaleClose.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SaleCloseActionPerformed(evt);
            }
        });
        jToolBar3.add(SaleClose);

        SaleLogOut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gnome_logout.png"))); // NOI18N
        SaleLogOut.setToolTipText("LogOut");
        SaleLogOut.setFocusable(false);
        SaleLogOut.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        SaleLogOut.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        SaleLogOut.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SaleLogOutActionPerformed(evt);
            }
        });
        jToolBar3.add(SaleLogOut);

        SaleSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icons/SaveBird.png"))); // NOI18N
        SaleSave.setText("Save");
        SaleSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SaleSaveActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar3, javax.swing.GroupLayout.DEFAULT_SIZE, 702, Short.MAX_VALUE)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel7Layout.createSequentialGroup()
                                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel16, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(96, 96, 96)
                                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(SaleRate, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(SaleQty, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(SaleDetail, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(SaleCustmer)
                                        .addComponent(SaleDate, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(SaleType, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                            .addGroup(jPanel7Layout.createSequentialGroup()
                                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(96, 96, 96)
                                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(SaleMethod, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(SaleCost, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel7Layout.createSequentialGroup()
                                .addComponent(SalesId, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(26, 26, 26)
                                .addComponent(ShowSaleId, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(SaleOtherDetail, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(CustmerLable, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 477, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGap(143, 143, 143)
                        .addComponent(SaleSave)
                        .addGap(317, 317, 317)))
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addComponent(jToolBar3, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(46, 46, 46)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(SalesId)
                        .addComponent(jLabel16)
                        .addComponent(SaleDate))
                    .addComponent(ShowSaleId, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(CustmerLable)
                    .addComponent(SaleCustmer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(22, 22, 22)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(SaleDetail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(SaleType)
                    .addComponent(SaleOtherDetail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(20, 20, 20)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(SaleQty, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(21, 21, 21)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(SaleRate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(jLabel14)
                        .addGap(11, 11, 11))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                        .addComponent(SaleCost)
                        .addGap(18, 18, 18)))
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(SaleMethod, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(SaleSave, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(57, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel7, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("     Sales      ", jPanel3);

        jPanel10.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Production/Conssumption", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial Black", 1, 14), new java.awt.Color(0, 204, 204))); // NOI18N

        ProSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icons/SaveBird.png"))); // NOI18N
        ProSave.setText("Save");
        ProSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ProSaveActionPerformed(evt);
            }
        });

        ProDetail.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Non", "Eggs", "Feed" }));
        ProDetail.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                ProDetailItemStateChanged(evt);
            }
        });

        ProQty.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                ProQtyKeyReleased(evt);
            }
        });

        jLabel21.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel21.setText("Type");

        jLabel23.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel23.setText("Quantity");

        ProType.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        ProType.setText("pru/con");

        jLabel22.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel22.setText("Detail:");

        jLabel27.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel27.setText("Date");

        jLabel31.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel31.setText("ID");

        ShowProId.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        ShowProId.setText("ID");

        ProDate.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        ProDate.setText("Date");

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel10Layout.createSequentialGroup()
                                .addComponent(jLabel31, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(ShowProId, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel10Layout.createSequentialGroup()
                                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel23, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel21, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel22, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel27, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(ProQty)
                                    .addComponent(ProDate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(ProDetail, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(ProType, javax.swing.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE)))))
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addGap(84, 84, 84)
                        .addComponent(ProSave)))
                .addContainerGap(59, Short.MAX_VALUE))
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel31)
                    .addComponent(ShowProId))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel27)
                    .addComponent(ProDate))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel22)
                    .addComponent(ProDetail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(9, 9, 9)
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel21)
                    .addComponent(ProType))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(ProQty, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel23))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(ProSave)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Stock Available", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial Black", 1, 18), new java.awt.Color(0, 204, 204))); // NOI18N

        jLabel24.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel24.setText("Hen");

        jLabel25.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel25.setText("Cocks");

        jLabel26.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel26.setText("Feed");

        jLabel32.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel32.setText("Eggs");

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel32, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel26, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel25, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(40, 40, 40)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(StockHen, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(StockCock, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(StockFeed, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE)
                    .addComponent(StockEggs, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE))
                .addContainerGap(100, Short.MAX_VALUE))
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel24, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(StockHen, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel25, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(StockCock, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel26)
                    .addComponent(StockFeed, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel32)
                    .addComponent(StockEggs, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jScrollPane2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Production", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monotype Corsiva", 1, 18), new java.awt.Color(0, 0, 204))); // NOI18N

        StockTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane2.setViewportView(StockTable);

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGap(55, 55, 55)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 584, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(62, 62, 62))
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(61, 61, 61))
        );

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("     Productin or Consumption      ", jPanel4);

        jScrollPane1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Life Spane", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monotype Corsiva", 1, 18), new java.awt.Color(0, 0, 204))); // NOI18N

        LifeSpaneTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        LifeSpaneTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LifeSpaneTableMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(LifeSpaneTable);

        jPanel15.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel28.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel28.setText("Date");

        jLabel29.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel29.setText("Detail:");

        jLabel30.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel30.setText("Type");

        LifeSpaneId.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        LifeSpaneId.setText("ID");

        jLabel34.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel34.setText("ID");

        LifeSpaneDetail.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Non", "Layer", "Boiler", " " }));

        LifeSpaneType.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        LifeSpaneType.setText("Type");

        LifeSpaneEdit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Actions-edit-redo-icon.png"))); // NOI18N
        LifeSpaneEdit.setText("Update");
        LifeSpaneEdit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LifeSpaneEditActionPerformed(evt);
            }
        });

        jLabel33.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        jLabel33.setText("Quantity");

        javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
        jPanel15.setLayout(jPanel15Layout);
        jPanel15Layout.setHorizontalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addGap(41, 41, 41)
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel34, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jLabel30, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jLabel29, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jLabel28, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jLabel33, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(LifeSpaneDetail, 0, 105, Short.MAX_VALUE)
                                .addComponent(LifeSpaneType, javax.swing.GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE)
                                .addComponent(LifeSpaneDate)
                                .addComponent(LifeSpaneId, javax.swing.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE))
                            .addComponent(LifeSpaneQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addGap(82, 82, 82)
                        .addComponent(LifeSpaneEdit)))
                .addGap(45, 45, 45))
        );
        jPanel15Layout.setVerticalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel15Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel34)
                    .addComponent(LifeSpaneId))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel28)
                    .addComponent(LifeSpaneDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel29)
                    .addComponent(LifeSpaneDetail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(9, 9, 9)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel30)
                    .addComponent(LifeSpaneType))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(LifeSpaneQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel33))
                .addGap(18, 18, 18)
                .addComponent(LifeSpaneEdit)
                .addContainerGap(30, Short.MAX_VALUE))
        );

        jPanel16.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        LifeSpaneSearch.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                LifeSpaneSearchKeyReleased(evt);
            }
        });

        StockLable5.setFont(new java.awt.Font("Monotype Corsiva", 1, 14)); // NOI18N
        StockLable5.setForeground(new java.awt.Color(0, 204, 204));
        StockLable5.setText("Search By Product ID");

        javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16);
        jPanel16.setLayout(jPanel16Layout);
        jPanel16Layout.setHorizontalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel16Layout.createSequentialGroup()
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel16Layout.createSequentialGroup()
                        .addGap(82, 82, 82)
                        .addComponent(LifeSpaneSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel16Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(StockLable5, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(153, Short.MAX_VALUE))
        );
        jPanel16Layout.setVerticalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel16Layout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addComponent(StockLable5, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(LifeSpaneSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(21, Short.MAX_VALUE))
        );

        StockLable6.setFont(new java.awt.Font("Monotype Corsiva", 1, 14)); // NOI18N
        StockLable6.setForeground(new java.awt.Color(0, 204, 204));
        StockLable6.setText(" Click on the Related Row to update The Record  ");

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 653, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(StockLable6))))
                .addContainerGap(29, Short.MAX_VALUE))
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addGap(42, 42, 42)
                        .addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(StockLable6, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 181, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(63, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("   Life Span Editing   ", jPanel12);

        FarmDisply.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        FarmDisply.setText("Farm Name Field");

        SalesId2.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        SalesId2.setText("To");

        UserDisply.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        UserDisply.setText("User Name");

        SalesId4.setFont(new java.awt.Font("Monotype Corsiva", 1, 18)); // NOI18N
        SalesId4.setText("Welcome");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.TRAILING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(SalesId4, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(UserDisply)
                .addGap(18, 18, 18)
                .addComponent(SalesId2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(FarmDisply)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(FarmDisply)
                    .addComponent(SalesId2)
                    .addComponent(UserDisply)
                    .addComponent(SalesId4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1))
        );

        jMenu1.setText("File");

        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.ALT_MASK));
        jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gnome_logout.png"))); // NOI18N
        jMenuItem1.setText("Sign Out");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);
        jMenu1.add(jSeparator1);

        jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Button-Close-icon.png"))); // NOI18N
        jMenuItem2.setText("Close");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);

        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-731)/2, (screenSize.height-627)/2, 731, 627);
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
       FarmDisply.setText(FarmName); 
       UserDisply.setText(UserName);
       OtherExpenseDetail.disable();
       SaleOtherDetail.disable();
    }//GEN-LAST:event_formWindowOpened

    private void SaleSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaleSaveActionPerformed
       int NoOfHen=Integer.parseInt(StockHen.getText());
       int NoOfCock=Integer.parseInt(StockCock.getText());
       int NoOfEggs=Integer.parseInt(StockEggs.getText());
       int NoOfFeed=Integer.parseInt(StockFeed.getText());
       if(SaleCustmer.getText().isEmpty()){
           JOptionPane.showMessageDialog(null, "Pleas Write the Customer's Name");
       }
       else if(SaleDetail.getSelectedItem().equals("Non")){
           JOptionPane.showMessageDialog(null, "Pleas Choose Correct Detail");
       }
       else if(SaleDetail.getSelectedItem().equals("Others")&&SaleOtherDetail.getText().isEmpty()){
           JOptionPane.showMessageDialog(null, "Please Write the Sales Type");
        }   
       else if(SaleQty.getText().isEmpty()){ 
       JOptionPane.showMessageDialog(null, "Pleas Type Quantity");
       }
       else if(SaleRate.getText().isEmpty()){ 
       JOptionPane.showMessageDialog(null, "Pleas Type Rate");
       }
       else if(SaleMethod.getSelectedItem().equals("Non")){
            JOptionPane.showMessageDialog(null, "Pleas Choose Correct Saling Mathod");
       }
       else if(SaleDetail.getSelectedItem().equals("Hen")&&Integer.parseInt(SaleQty.getText())>NoOfHen||
               SaleDetail.getSelectedItem().equals("Cock")&&Integer.parseInt(SaleQty.getText())>NoOfCock||
               SaleDetail.getSelectedItem().equals("Feed")&&Integer.parseInt(SaleQty.getText())>NoOfFeed||
               SaleDetail.getSelectedItem().equals("Eggs")&&Integer.parseInt(SaleQty.getText())>NoOfEggs){
       JOptionPane.showMessageDialog(null,"Stock that you want is not Available");
       }
       else{
        try{
        String sql;
        sql = "insert into sales (Date,user,custmer,detail,type,quantity,rate,cost,method,FarmName) values (?,?,?,?,?,?,?,?,?,?)";
        pst=conn.prepareStatement(sql);
        pst.setString(1, SaleDate.getText());
        pst.setString(2, UserDisply.getText());
        pst.setString(3, SaleCustmer.getText());
        String value1=SaleDetail.getSelectedItem().toString();
        pst.setString(4, value1);
        pst.setString(5, SaleType.getText());
        pst.setString(6, SaleQty.getText());
        pst.setString(7, SaleRate.getText());
        pst.setString(8, SaleCost.getText());
        String value2=SaleMethod.getSelectedItem().toString();
        pst.setString(9, value2);
        pst.setString(10, FarmDisply.getText());
        pst.execute();
        JOptionPane.showMessageDialog(null, "Sved");
        SaleType.setText("Type");
        SaleDetail.setSelectedIndex(0);
        SaleCustmer.setText("");
        SaleQty.setText("");
        SaleRate.setText("");
        SaleCost.setText("Cost");
        SaleMethod.setSelectedIndex(0);
        }
        catch(Exception e){
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, e);
        }finally{
        try{
        rs.close();
        pst.close();
        }
        catch(Exception e){}
        }
    }
    UpdateStock();
    UpdateTable();
    }//GEN-LAST:event_SaleSaveActionPerformed

    private void ProSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ProSaveActionPerformed
        if(ProQty.getText().isEmpty()){
            JOptionPane.showMessageDialog(null, "Please Type The Quantity");
        }
        else if (ProDetail.getSelectedItem().equals("Non")){
            JOptionPane.showMessageDialog(null, "Please Choose Correct Detail");
        }
        else{
        try{
        String sql;
        sql = "insert into journal (Date,user,detail,type,quantity,FarmName) values (?,?,?,?,?,?)";
        pst=conn.prepareStatement(sql);
        pst.setString(1, ProDate.getText());
        pst.setString(2, UserDisply.getText());
        String value1=ProDetail.getSelectedItem().toString();
        pst.setString(3, value1);
        pst.setString(4, ProType.getText());
        pst.setString(5, ProQty.getText());
        pst.setString(6, FarmDisply.getText());
        pst.execute();
        JOptionPane.showMessageDialog(null, "Sved");
        ProDetail.setSelectedIndex(0);
        ProQty.setText("");
        }
        catch(Exception e){
         JOptionPane.showMessageDialog(null, e);
        }       
        finally{
        try{
        rs.close();
        pst.close();
        }
        catch(Exception e){}
        }
        }
        UpdateTable();
        UpdateStock();
    }//GEN-LAST:event_ProSaveActionPerformed

    private void LifeSpaneTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LifeSpaneTableMouseClicked
        try{
        int SlectedRow=LifeSpaneTable.getSelectedRow();
        String TableClicked=(LifeSpaneTable.getModel().getValueAt(SlectedRow,0).toString());
        String sql = "Select ID,Date,Detail,Type,Quantity from lifeSpane where ID='"+TableClicked+"'";
        pst=conn.prepareStatement(sql);
        rs=pst.executeQuery();
        if(rs.next()){
            String Show1=rs.getString("ID");
            LifeSpaneId.setText(Show1);
            String Show2=rs.getString("Date");
            LifeSpaneDate.setText(Show2);
            String Show3=rs.getString("Type");
            LifeSpaneType.setText(Show3);
            String Show4=rs.getString("Quantity");
            LifeSpaneQuantity.setText(Show4);
        }
        }
        catch(Exception e){
        JOptionPane.showMessageDialog(null, e);
        }finally{
        try{
        rs.close();
        pst.close();
        }
        catch(Exception e){}
        }
    }//GEN-LAST:event_LifeSpaneTableMouseClicked

    private void LifeSpaneEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LifeSpaneEditActionPerformed
        if (LifeSpaneQuantity.getText().isEmpty()){
        JOptionPane.showMessageDialog(null, "Please Write the Quantity");
        }
        else {
        try{
        String Id=LifeSpaneId.getText();
        String DateUpdate = LifeSpaneDate.getText();
        String value=LifeSpaneDetail.getSelectedItem().toString();
        String QuantityUdate =LifeSpaneQuantity.getText();
        String User = UserDisply.getText();
        if(DateUpdate.isEmpty()){
        JOptionPane.showMessageDialog(null, "Please make sure the date is correct");
        }
        else{
        String sql="update lifeSpane set Date='"+DateUpdate+"',Detail='"+value+"',Quantity='"+QuantityUdate+"'"
                + ",user ='"+User+"' where ID='"+Id+"'";
        pst=conn.prepareStatement(sql);
        pst.execute();
        JOptionPane.showMessageDialog(null,"Saved");
        }
        }
        catch(Exception e){
            JOptionPane.showMessageDialog(null, e);
        }finally{
        try{
        rs.close();
        pst.close();
        }
        catch(Exception e){}
        }
        UpdateTable();
        LifeSpaneDate.setText("");
        LifeSpaneQuantity.setText("");
        }
        UpdateTable();
    }//GEN-LAST:event_LifeSpaneEditActionPerformed

    private void LifeSpaneSearchKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_LifeSpaneSearchKeyReleased
        try{
        String sql="select*from lifeSpane where ID=?";
        pst=conn.prepareStatement(sql);
        pst.setString(1,LifeSpaneSearch.getText());
        rs=pst.executeQuery();
        if(rs.next()){
        String Search1=rs.getString("ID");
        LifeSpaneId.setText(Search1);
        String Search2=rs.getString("Date");
        LifeSpaneDate.setText(Search2);
        String Search3=rs.getString("Type");
        LifeSpaneType.setText(Search3);
        String Search4=rs.getString("Quantity");
        LifeSpaneQuantity.setText(Search4);
        }
        }
        catch(Exception e){
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, e);
        }finally{
        try{
        rs.close();
        pst.close();
        }
        catch(Exception e){}
        }
    }//GEN-LAST:event_LifeSpaneSearchKeyReleased

    private void SaleQtyKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_SaleQtyKeyReleased
        String GetRate =SaleRate.getText();
        String GetQty=SaleQty.getText();
        if (SaleRate.getText().isEmpty()){
             GetRate="0";
        }
         if (SaleQty.getText().isEmpty()){
             GetQty="0";
         }
        double Quantity=Double.parseDouble(GetQty);      
        double Rate = Double.parseDouble(GetRate);
        double GetCost=Rate*Quantity;
        String ConvToString = Double.toString(GetCost);
        SaleCost.setText(ConvToString);
        try{
        String sql="select sr, max(sr) from sales";
        pst=conn.prepareStatement(sql);
        rs=pst.executeQuery();
        String MaxID=rs.getString("max(sr)");
        int ConvToInt= Integer.parseInt(MaxID);
        int Increment=ConvToInt+1;
        ShowSaleId.setText(String.valueOf(Increment));
        }catch (Exception e){
         e.printStackTrace();
         JOptionPane.showMessageDialog(null, e);
     }finally{
        try{
        rs.close();
        pst.close();
        }
        catch(Exception e){}
        }
    }//GEN-LAST:event_SaleQtyKeyReleased

    private void SaleRateKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_SaleRateKeyReleased
        String GetRate =SaleRate.getText();
        String GetQty=SaleQty.getText();
        if (SaleRate.getText().isEmpty()){
        GetRate="0";
        }
         if (SaleQty.getText().isEmpty()){
             GetQty="0";
         }       
        double Quantity=Double.parseDouble(GetQty);      
        double Rate= Double.parseDouble(GetRate);
        double GetCost=Rate*Quantity;
        String ConvToString = Double.toString(GetCost);
        SaleCost.setText(ConvToString);
    }//GEN-LAST:event_SaleRateKeyReleased

    private void SaleDetailItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_SaleDetailItemStateChanged
        String GetValue=(String)SaleDetail.getSelectedItem();
        if(GetValue.equals("Hen")||GetValue.equals("Cock")||GetValue.equals("Eggs")||
           GetValue.equals("Layer")||GetValue.equals("Boiler")||GetValue.equals("Feed")){
        SaleType.setText("Sale");
        SaleOtherDetail.disable();
        }
        else{
        SaleType.setText("Sale");
        SaleOtherDetail.enable();
        }
    }//GEN-LAST:event_SaleDetailItemStateChanged

    private void ProDetailItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_ProDetailItemStateChanged
        String GetValue=(String)ProDetail.getSelectedItem();
        if(GetValue.equals("Eggs")){
        ProType.setText("Production");
        }
        else if(GetValue.equals("Feed")){
        ProType.setText("Consumption");
        }
        else if(GetValue.equals("Non")){
        ProType.setText("pru/con");
        }
    }//GEN-LAST:event_ProDetailItemStateChanged

    private void ProQtyKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_ProQtyKeyReleased
        if (!ShowJournalId.getText().isEmpty()){
            JOptionPane.showMessageDialog(null, "Save the Journal first");
        }
        else{
        try{
        String sql="select sr, max(sr) from journal";
        pst=conn.prepareStatement(sql);
        rs=pst.executeQuery();
        String MaxID=rs.getString("max(sr)");
        int ConvToInt= Integer.parseInt(MaxID);
        int Increment=ConvToInt+1;
        ShowProId.setText(String.valueOf(Increment));
     }catch (Exception e){
         e.printStackTrace();
         JOptionPane.showMessageDialog(null, e);
     }finally{
        try{
        rs.close();
        pst.close();
        }
        catch(Exception e){}
        }
     }  
    }//GEN-LAST:event_ProQtyKeyReleased

    private void JournalSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JournalSaveActionPerformed
        JournalSaved ();
    }//GEN-LAST:event_JournalSaveActionPerformed

    private void JournalDetailItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_JournalDetailItemStateChanged
        String GetValue=(String)JournalDetail.getSelectedItem();
        if(GetValue.equals("Hen")||GetValue.equals("Cock")||GetValue.equals("Eggs")||
            GetValue.equals("Layer")||GetValue.equals("Boiler")||GetValue.equals("Feed")){
            JournalType.setText("Purchase");
            OtherExpenseDetail.disable();
        }
        else if(JournalDetail.getSelectedItem().equals("Salary")){
            JournalType.setText("Expense");
            OtherExpenseDetail.disable();
        }
        else if(JournalDetail.getSelectedItem().equals("Others")) {
            JournalType.setText("Expense");
            OtherExpenseDetail.enable();
        }
    }//GEN-LAST:event_JournalDetailItemStateChanged

    private void JournalRateKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_JournalRateKeyReleased
        String GetRate =JournalRate.getText();
        String GetQty=JournalQty.getText();
        if (JournalRate.getText().isEmpty()){
            GetRate="0";
        }
        if (JournalQty.getText().isEmpty()){
            GetQty="0";
        }
        double Quantity=Double.parseDouble(GetQty);
        double Rate= Double.parseDouble(GetRate);
        double GetCost=Rate*Quantity;
        String ConvToString = Double.toString(GetCost);
        JournalCost.setText(ConvToString);
    }//GEN-LAST:event_JournalRateKeyReleased

    private void JournalQtyKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_JournalQtyKeyReleased
        String GetRate =JournalRate.getText();
        String GetQty=JournalQty.getText();
        if (JournalRate.getText().isEmpty()){
            GetRate="0";
        }
        if (JournalQty.getText().isEmpty()){
            GetQty="0";
        }
        double Quantity=Double.parseDouble(GetQty);
        double Rate= Double.parseDouble(GetRate);
        double GetCost=Rate*Quantity;
        String ConvToString = Double.toString(GetCost);
        JournalCost.setText(ConvToString);
        try{
            String sql="select sr, max(sr) from journal";
            pst=conn.prepareStatement(sql);
            rs=pst.executeQuery();
            String MaxID=rs.getString("max(sr)");
            int ConvToInt= Integer.parseInt(MaxID);
            int Increment=ConvToInt+1;
            ShowJournalId.setText(String.valueOf(Increment));
            if(evt.getKeyCode() == KeyEvent.VK_BACK_SPACE || evt.getKeyCode() == KeyEvent.VK_DELETE){
                ShowJournalId.setText("");
            }
        }
        catch (Exception e){
            e.printStackTrace();
            JOptionPane.showMessageDialog(null, e);
        }finally{
            try{
                rs.close();
                pst.close();
            }
            catch(Exception e){}
        }
    }//GEN-LAST:event_JournalQtyKeyReleased

    private void JournalSavetoolBarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JournalSavetoolBarActionPerformed
       JournalSaved ();
    }//GEN-LAST:event_JournalSavetoolBarActionPerformed

    private void JournalCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JournalCloseActionPerformed
        dispose();
    }//GEN-LAST:event_JournalCloseActionPerformed

    private void JournalLogOutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JournalLogOutActionPerformed
        new LoginForm().setVisible(true);
        dispose();
    }//GEN-LAST:event_JournalLogOutActionPerformed

    private void SaleSave1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaleSave1ActionPerformed
       if(SaleCustmer.getText().isEmpty()){
           JOptionPane.showMessageDialog(null, "Pleas Write the Customer's Name");
       }
       else if(SaleDetail.getSelectedItem().equals("Non")){
           JOptionPane.showMessageDialog(null, "Pleas Choose Correct Detail");
       }
        else if(SaleDetail.getSelectedItem().equals("Others")&&SaleOtherDetail.getText().isEmpty()){
           JOptionPane.showMessageDialog(null, "Please Write the Sales Type");
        }   
       else if(SaleQty.getText().isEmpty()){ 
       JOptionPane.showMessageDialog(null, "Pleas Type Quantity");
       }
       else if(SaleRate.getText().isEmpty()){ 
       JOptionPane.showMessageDialog(null, "Pleas Type Rate");
       }
       else if(SaleMethod.getSelectedItem().equals("Non")){
            JOptionPane.showMessageDialog(null, "Pleas Choose Correct Saling Mathod");
       }
       else{
        try{
        String sql;
        sql = "insert into sales (Date,user,custmer,detail,type,quantity,rate,cost,method) values (?,?,?,?,?,?,?,?,?)";
        pst=conn.prepareStatement(sql);
        pst.setString(1, SaleDate.getText());
        pst.setString(2, UserDisply.getText());
        pst.setString(3, SaleCustmer.getText());
        String value1=SaleDetail.getSelectedItem().toString();
        pst.setString(4, value1);
        pst.setString(5, SaleType.getText());
        pst.setString(6, SaleQty.getText());
        pst.setString(7, SaleRate.getText());
        pst.setString(8, SaleCost.getText());
        String value2=SaleMethod.getSelectedItem().toString();
        pst.setString(9, value2);
        pst.execute();
        JOptionPane.showMessageDialog(null, "Sved");
        SaleType.setText("Type");
        SaleDetail.setSelectedIndex(0);
        SaleCustmer.setText("");
        SaleQty.setText("");
        SaleRate.setText("");
        SaleCost.setText("Cost");
        }
        catch(Exception e){
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, e);
        }finally{
        try{
        rs.close();
        pst.close();
        }
        catch(Exception e){}
        
        }
    }
    }//GEN-LAST:event_SaleSave1ActionPerformed

    private void SaleCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaleCloseActionPerformed
        dispose();
    }//GEN-LAST:event_SaleCloseActionPerformed

    private void SaleLogOutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaleLogOutActionPerformed
        new LoginForm().setVisible(true);
        dispose();
    }//GEN-LAST:event_SaleLogOutActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        new LoginForm().setVisible(true);
        dispose();
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        dispose();
    }//GEN-LAST:event_jMenuItem2ActionPerformed
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(UserUpdate.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(UserUpdate.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(UserUpdate.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(UserUpdate.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new UserUpdate().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel CustmerLable;
    private javax.swing.JLabel FarmDisply;
    private javax.swing.JButton JournalClose;
    private javax.swing.JLabel JournalCost;
    private javax.swing.JComboBox JournalDetail;
    private javax.swing.JButton JournalLogOut;
    private javax.swing.JComboBox JournalMethod;
    private javax.swing.JTextField JournalName;
    private javax.swing.JTextField JournalQty;
    private javax.swing.JTextField JournalRate;
    private javax.swing.JButton JournalSave;
    private javax.swing.JButton JournalSavetoolBar;
    private javax.swing.JLabel JournalType;
    private javax.swing.JTextField LifeSpaneDate;
    private javax.swing.JComboBox LifeSpaneDetail;
    private javax.swing.JButton LifeSpaneEdit;
    private javax.swing.JLabel LifeSpaneId;
    private javax.swing.JTextField LifeSpaneQuantity;
    private javax.swing.JTextField LifeSpaneSearch;
    private javax.swing.JTable LifeSpaneTable;
    private javax.swing.JLabel LifeSpaneType;
    private javax.swing.JTextField OtherExpenseDetail;
    private javax.swing.JLabel ProDate;
    private javax.swing.JComboBox ProDetail;
    private javax.swing.JTextField ProQty;
    private javax.swing.JButton ProSave;
    private javax.swing.JLabel ProType;
    private javax.swing.JLabel PurchasedDate;
    private javax.swing.JButton SaleClose;
    private javax.swing.JLabel SaleCost;
    private javax.swing.JTextField SaleCustmer;
    private javax.swing.JLabel SaleDate;
    private javax.swing.JComboBox SaleDetail;
    private javax.swing.JButton SaleLogOut;
    private javax.swing.JComboBox SaleMethod;
    private javax.swing.JTextField SaleOtherDetail;
    private javax.swing.JTextField SaleQty;
    private javax.swing.JTextField SaleRate;
    private javax.swing.JButton SaleSave;
    private javax.swing.JButton SaleSave1;
    private javax.swing.JLabel SaleType;
    private javax.swing.JLabel SalesId;
    private javax.swing.JLabel SalesId1;
    private javax.swing.JLabel SalesId2;
    private javax.swing.JLabel SalesId4;
    private javax.swing.JLabel ShowJournalId;
    private javax.swing.JLabel ShowProId;
    private javax.swing.JLabel ShowSaleId;
    private javax.swing.JLabel StockCock;
    private javax.swing.JLabel StockEggs;
    private javax.swing.JLabel StockFeed;
    private javax.swing.JLabel StockHen;
    private javax.swing.JLabel StockLable5;
    private javax.swing.JLabel StockLable6;
    private javax.swing.JTable StockTable;
    private javax.swing.JLabel UserDisply;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel16;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JToolBar jToolBar3;
    // End of variables declaration//GEN-END:variables
}
